<template>
  <div style="margin: 10px">
    <a-spin :spinning="loading">
      <div style="width: 700px">
        <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
          <!-- <a-form-item label="推送提示">
            pushDepartment
          </a-form-item> -->
          <a-form-item label="推送提示">
            <a-textarea :rows="6" v-decorator="['tipContext']" />
          </a-form-item>
          <a-form-item style="text-align: center">
            <a-button type="primary" @click="handlesave">确定</a-button>
          </a-form-item>
        </a-form>
      </div>

    </a-spin>
  </div>
</template>
<script>
import { tranDate } from '@/utils/util'
import { getTipDetail, saveTip } from '@/api/tip'

export default {
  data () {
    return {
      form: this.$form.createForm(this),
      detail: {},
      loading: false,
    }
  },
  created () {
    this.init()
  },
  methods: {
    async init () {
      this.form.resetFields()
      const { data } = await getTipDetail({ tipName: 'pushDepartment' })
      console.log(data)
      this.detail = data
      this.form.setFieldsValue({ tipContext: data.tipContext })
    },

    async handlesave () {
      const {
        form: { validateFields }
      } = this

      validateFields((errors, values) => {
        let params = {
          tipName: 'pushDepartment',
          ...this.data,
          ...values
        }
        if (!errors) {
          this.loading = true
          setTimeout(() => {
            saveTip(params).then(res => {
              this.init()
              this.loading = false
            })
          }, 100)
        }
      })

    }
  }

}
</script>
